<template>
    <div class="qualification">
        <h5>
            <span>塞罕云资质</span>
            <span class="add my-background" @click="addClick(1)">添加</span>
        </h5>
        <div class="table-box">
            <el-table  :data="qualification"  style="width: 100%"  >
                <el-table-column  fixed  prop="name"  label="资质名称"  width="250"></el-table-column>
                <el-table-column  label="资质内容" >
                    <template slot-scope="scope">
                        <img style="width:210px" :src="scope.row.content" alt="">
                    </template>
                </el-table-column>
                <el-table-column  fixed="right"  label="操作"  width="120">
                    <template slot-scope="scope">
                        <el-button type="text" @click="addClick(2,scope.row)" size="small">
                            <span style="padding:5px;">编辑</span>
                        </el-button>
                        <el-button type="text" @click="delClick(scope.row.id)" size="small">
                            <span style="padding:5px;">删除</span>
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            qualification: []
        }
    },
    mounted(){
        this.getqualificationData()
    },
    methods:{
        //删除
        delClick(id){
            this.$confirm('此操作将永久删除该资质, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.axios.post('/operate/sys/Certificate/delete?id='+id).then(res=>{
                    this.$message({
                        type: 'success',
                        message: '删除成功!'
                    });
                    this.getqualificationData()
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });          
            });
            
        },
        //添加、编辑
        addClick(type,n){
            this.$router.push({path:'/index/qualificationEdit',query:{type:type,receiveData:n}})
        },
        //获取资质列表数据
        getqualificationData(){
            this.axios.get('/operate/sys/Certificate/list').then(res=>{
                this.qualification=res.data.List
            })
        }
    }
}
</script>

<style scoped>
.qualification>h5{
    display: flex;
    justify-content: space-between;
}
.qualification>h5 .add{
    display: inline-block;
    font-size: 15px;
    width: 62px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 2px;
    color: #fff;
    /* background: rgb(110, 163, 231); */
}
.table-box{
    margin-top: 40px;
}
</style>